require 'merge/field'
require 'csv'
require 'math'

module Merge
  
  class MultipleField < Field
    
    def get_probabilistic_field(services)
      likes = Hash.new 0.0
      services.each { |s|
        data = s.crawl.data
        if data.attribute_present?(name)  then
          value = data.send(name)
          #sample_space[value] = Math::tsum(sample_space[value],data.trust_of(name))
          if !value.nil? then
            CSV::Reader.parse(value) do |row|
              row.each {|l| likes[l] = Math::tsum(likes[l],data.trust_of(name)) }
            end 
          end
        end
      }
      likes
    end
    
  end
  
end